﻿//======================================================================
//
//	Cross-Platform XNA Menu System
//  http://cpxms.codeplex.com/
//
//  All code and content licensed under Microsoft Public License (Ms-PL)	
//
//======================================================================
//
//	File:		MenuProjectReader.cs
//
//	Author:		MJP
//
//	Date:		05/17/09
//
//======================================================================

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Xml;
using System.Xml.Serialization;
using System.Drawing.Design;
using System.IO;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace CPXMenu
{
    /// <summary>
    /// Content pipeline support class for loading MenuProject objects.
    /// </summary>
    public class MenuProjectReader : ContentTypeReader<MenuProject>
    {
        /// <summary>
        /// Reads instanced model data from an XNB file.
        /// </summary>
        protected override MenuProject Read(ContentReader input, MenuProject existingInstance)
        {
            string inputString = input.ReadString();

            XmlSerializer serializer = new XmlSerializer(typeof(MenuProject), MenuProject.GetSerializationTypes());
            StringReader reader = new StringReader(inputString);
            MenuProject project = (MenuProject)serializer.Deserialize(reader);

            project.Initialize(input.ContentManager);

            return project;
        }
    }
}